package com.itrh.auth.controller;

import com.itrh.auth.service.IRoleMenuService;
import com.itrh.auth.domain.RoleMenu;
import com.itrh.auth.query.RoleMenuQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.itrh.org.util.Result;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/roleMenu")
public class RoleMenuController {
    @Autowired
    public IRoleMenuService roleMenuService;



    @PutMapping
    public Result addOrUpdate(@RequestBody RoleMenu roleMenu){
        return roleMenuService.saveOrUpdate(roleMenu);
    }

    @DeleteMapping(value="/{id}")
    public Result delete(@PathVariable("id") Long id) {
        return roleMenuService.deleteById(id);
    }
	
    //获取用户
    @GetMapping("/{id}")
    public Result get(@PathVariable("id")Long id) {
        return roleMenuService.selectById(id);
    }

    @GetMapping
    public Result list() {
        return roleMenuService.selectAll();
    }

    @PostMapping
    public Result pageList(@RequestBody RoleMenuQuery query) {
        return roleMenuService.pageList(query);
    }

    @PatchMapping
    public Result batchRemove(@RequestBody List<Long> ids){
        return roleMenuService.batchRemove(ids);
    }

    @GetMapping("/menu")
    public Result getMenuByRoleId(HttpServletRequest request) {
        return roleMenuService.getMenuByRoleId(request);
    }
}
